﻿Imports System.Data
Imports System.Data.OleDb
Imports geraLaudosAutomatico.conexao
Imports System.Text

Public Class drogaRelatorioDAO

    Private sql As New StringBuilder
    Private i As Integer

    Public Function insereDrogaRelatorio(ByVal drogasRelatorio As List(Of drogaRelatorioVO)) As Integer

        For Each DROGA In drogasRelatorio
            Try
                Dim objConn As New conexao
                Dim oComando As New OleDbCommand
                Dim i As Integer = 0
                sql.Clear()
                sql.Append("INSERT INTO DROGA_RELATORIO (ID_REGISTRO,DATA_REGISTRO,ID_DROGA,MASSA,RESULTADO)")
                sql.Append(" VALUES ")
                sql.Append("(@ID_REGISTRO,@DATA_REGISTRO,@ID_DROGA,@MASSA,@RESULTADO)")
                oComando = New OleDbCommand(sql.ToString, objConn.abreConexao)
                oComando.Parameters.AddWithValue("@ID_REGISTRO", DROGA.ID_REGISTRO)
                oComando.Parameters.AddWithValue("@DATA_REGISTRO", DateTime.Parse(Now()))
                oComando.Parameters.AddWithValue("@ID_DROGA", DROGA.ID_DROGA)
                oComando.Parameters.AddWithValue("@MASSA", DROGA.MASSA)
                oComando.Parameters.AddWithValue("@RESULTADO", DROGA.RESULTADO)
                i = oComando.ExecuteNonQuery
            Catch ex As Exception
                Throw ex
            End Try
        Next
        Return i
    End Function
End Class